<?php 
session_cache_expire(999999999);
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}

if(isset($_SESSION['lang']))
$lang = $_SESSION['lang'];
if (empty($lang) || $lang == "EN") {
	include "../value/value_en.php";
} else if($lang == "VN") {
	include "../value/value_vn.php";
}
else {
	include "../value/value_kr.php";
}
$id_employee=$_REQUEST['idem'];
include '../operations/connection.php';	
if(isset($_REQUEST['flagaction'])){
	if($_REQUEST['flagaction']=="newlb"){
		$sql="insert into list_lable(LableName,IDEmployee) values ('".$_REQUEST['lablename']."','".$id_employee."')";
		mysql_query($sql);
	}else if($_REQUEST['flagaction']=="editlb"){
		$sql="update list_lable set list_lable.LableName='".$_REQUEST['lablename']."' where list_lable.IDLable=".$_REQUEST['lableid']."";
		mysql_query($sql);
	}else if($_REQUEST['flagaction']=="deletelb"){
		$sql="DELETE from list_lable where list_lable.IDLable=".$_REQUEST['lableid']."";
		mysql_query($sql);
	}
}
mysql_query("UPDATE listapprove SET IDLabel = IDStatus WHERE IDStatus > 10");
mysql_query("UPDATE listapprove SET IDStatus=1 WHERE IDStatus > 10");
$sql="SELECT l.IDLable,l.LableName, 
(SELECT COUNT(*) FROM approvedoc a WHERE a.IDLabel=l.IDLable) as slApprove,
(SELECT COUNT(*) FROM listapprove la,approvedoc a WHERE la.IDLabel=l.IDLable AND a.IDGroupApprove=la.IDGroupApprove AND la.IDEmployee='$id_employee') as slgApprove,
(SELECT COUNT(*) FROM list_reference lr,approvedoc a WHERE lr.IDLabel=l.IDLable AND a.IDGroupApprove=lr.id_group AND lr.id_employee='$id_employee') as slreference
FROM list_lable l WHERE l.IDEmployee='$id_employee';";
//echo "<br>".$sql;
	$manglibrary=mysql_query($sql);
?>

            
            <?php 
												
				if(count($manglibrary)>0){
					$vitri=1;
					while($row=mysql_fetch_array($manglibrary)){
						?>
						<li>
							<table style="width:100%;border:1;">
								<tr>
									<td>
										<span><img src="images/index_25.gif" alt="" />
										<a href="library.php?content=list-library-content&liname=<?php echo $row[LableName];?>&libraryid=<?php echo $row[IDLable];?>" ><?php echo $row[LableName]?>
										<?php 
											$soluong=$row[slApprove]+$row[slgApprove]+$row[slreference];
											echo " ( ".$soluong." )";
										?>
										</a> </span>
										<span style="float: right" ><a href="#?w=350" onclick="getresult('<?=$row[LableName]?>',<?=$row[IDLable]?>,<?=$soluong?>,this);" rel="popup_name2" class="poplight"><img src="images/config.png" alt="" /></a></span>
									</td>
								</tr>
							</table>
						</li>
						<?php 
					}
				}
			?>
<?php  mysql_close($connection);?>